package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Criticism;
import com.skyolder.milkbee.repository.CriticismRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Criticism.
 */
@Service
@Transactional
public class CriticismService {

    private final Logger log = LoggerFactory.getLogger(CriticismService.class);
    
    @Inject
    private CriticismRepository criticismRepository;

    /**
     * Save a criticism.
     *
     * @param criticism the entity to save
     * @return the persisted entity
     */
    public Criticism save(Criticism criticism) {
        log.debug("Request to save Criticism : {}", criticism);
        Criticism result = criticismRepository.save(criticism);
        return result;
    }

    /**
     *  Get all the criticisms.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Criticism> findAll(Pageable pageable) {
        log.debug("Request to get all Criticisms");
        Page<Criticism> result = criticismRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one criticism by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Criticism findOne(Long id) {
        log.debug("Request to get Criticism : {}", id);
        Criticism criticism = criticismRepository.findOne(id);
        return criticism;
    }

    /**
     *  Delete the  criticism by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Criticism : {}", id);
        criticismRepository.delete(id);
    }
}
